<template>
  <div class="box">
    <u-navbar title="核销订单">
      <div slot="right" style="margin-right:24rpx;">
        <u-icon name="scan" size="40"></u-icon>
      </div>
    </u-navbar>
    <div class="take">
      <u-input v-model="qrCode" placeholder="订单号核销" :custom-style="{'background':'#ededed','padding-left':'20rpx','border-radius':'10rpx'}"></u-input>
      <div class="submit" @click="take">订单核销</div>
    </div>
  </div>
</template>

<script>
import { orderTake } from "@/api/order";
export default {
  data() {
    return {
      qrCode: "", //核销码
    };
  },
  onLoad(options) {
    let order = JSON.parse(decodeURIComponent(options.data));
    this.routerVal = order;
    this.qrCode = order.verificationCode;
  },
  methods: {
    async take() {
      uni.showLoading({
        title: "加载中",
        mask: "true",
      });
      let res = await orderTake(this.routerVal.sn, this.qrCode);
      if (res.data.success) {
        uni.showToast({
          title: "核销成功!",
          duration: 2000,
          icon: "none",
        });

        setTimeout(() => {
          uni.navigateBack();
        }, 500);
      }
      uni.hideLoading();
    },
  },
};
</script>

<style lang="scss" scoped>
@import "./style.scss";
.box {
  padding: 34rpx;
}
</style>